<template>
  <div id="nurseryCourse_manage" class="container">
    <div class="content">
      <div class="title">托育课程</div>
      <div class="panel">
        <div class="condition">
          <div class="row_one">
            <el-select
              style="width:2.03rem;float: left;margin-left:.1rem;"
              clearable
              v-model="tabledisplayObj.courseId"
              placeholder="请选择课程类型"
            >
              <el-option
                v-for="item in selectCourseList"
                :key="item.value"
                :label="item.name"
                :value="item.value"
              ></el-option>
            </el-select>

            <el-input
              style="width: 3rem;margin-left:.1rem;"
              placeholder="搜索 课程名称"
              v-model="tabledisplayObj.studentName"
              class="input_search"
              clearable
            ></el-input>
            <div @click="searchCoupon()" class="search_btn" style="margin-left:0.1rem;">搜索</div>
            <div class="right_btn" @click="nurseryCourse_add">新增课程</div>
          </div>
        </div>
        <div>
          <table class="table" cellspacing="0">
            <thead class="thead">
              <tr>
                <td style="width: 4rem;">课程名称</td>
                <td style="width: 2rem;">课程类型</td>
                <td style="width: 2rem;">适合年龄</td>
                <td style="width: 2rem;">课程周期</td>
                <td style="width: 4rem;">创建时间</td>
                <td style="width: 2rem;">状态</td>
                <td style="width: 4rem;">操作</td>
              </tr>
            </thead>
            <tbody class="tbody">
              <tr>
                <td>能力发展</td>
                <td>亲子课程</td>
                <td>0~12岁</td>
                <td>24周</td>
                <td>2019-01-01 18:00</td>
                <td>启用</td>
                <td>
                  <span class="operate_btn">启用&nbsp;</span>
                  <span class="operate_btn">查看&nbsp;</span>
                  <span class="operate_btn">删除&nbsp;</span>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <el-pagination
          class="page"
          layout="total, sizes, prev, pager, next, jumper"
          :current-page="tabledisplayObj.currPage"
          @size-change="pageSizeChange"
          @current-change="tabledisplayChangePage"
          :total="tabledisplayObj.total"
        ></el-pagination>
        <!-- 新增课程 -->
        <el-dialog
          :title="addCoursePopup.title"
          :visible.sync="addCoursePopup.visible"
          :close-on-click-modal="false"
          :width="addCoursePopup.width"
        >
          <nurseryCourseAdd ref="nurseryCourseAdd" @callback="closeAdd"></nurseryCourseAdd>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
let vm;
let user;
import nurseryCourseAdd from "./common/nursery_course_add";
export default {
  data() {
    return {
      tabledisplayObj: {
        currPage: 1,
        pageSize: 10,
        total: 0,
        studentName: "",
        courseId: ""
      },
      addCoursePopup: {
        title: "新增课程",
        visible: false,
        width:"60%"
      },
      selectCourseList: [],
      nurseryCourseDataList: [] //课程列表
    };
  },
  components: { nurseryCourseAdd },
  methods: {
    /**新增课程 */
    nurseryCourse_add() {
      vm.addCoursePopup.visible = true;
      vm.visiblePopup("nurseryCourseAdd");
    },
    /**初始化组件 */
    visiblePopup(componentName,data=null){
				if(this.$refs[componentName]){
					this.$refs[componentName].init(data);
				}
				else{
					this.$nextTick(()=>{
						this.$refs[componentName].init(data);
					})
				}
			},
    closeAdd() {},
    /**
     * 初始化数据
     */
    initData() {
      this.getData(vm.tabledisplayObj);
    },
    /**
     * 抽取出来获取列表
     */
    getData(paras) {},
    pageSizeChange: function(val) {
      //页条数发生改变
      vm.tabledisplayObj.pageSize = val;
      vm.initData();
    },
    /**表格显示形式翻页 */
    tabledisplayChangePage(val) {
      vm.tabledisplayObj.currPage = val;
      vm.initData();
    },
    /**
     * 搜索
     */
    searchCoupon() {
      vm.tabledisplayObj.currPage = 1;
      vm.initData();
    }
  },
  mounted() {
    vm = this;
    user = tool.getItem(lsKey.user, true); //得到当前用户信息
    //获取数据字典
    let dicdata = tool.getItem(lsKey.dict, true);
    this.initData();
  }
};
</script>

<style lang="scss">
#nurseryCourse_manage {
  .el-input__inner {
    border-radius: 0.08rem;
    font-size: 0.16rem;
    color: #666666;
    height: 0.36rem;
    line-height: 0.36rem;
  }
  .el-input__icon {
    line-height: 0.36rem;
  }

  .input_search {
    .el-input__inner {
      background-color: rgb(247, 248, 250);
    }
  }
  .el-breadcrumb__separator {
    color: #999999;
  }
  .el-breadcrumb__inner.is-link {
    font-weight: 400;
    color: #141414;
  }
  .el-breadcrumb__inner.is-link:hover {
    color: #3885f8;
  }
  .el-breadcrumb__item:last-child .el-breadcrumb__inner {
    color: #999999;
  }
  .right_btn {
    background-image: url(~@/assets/img/clue_manage/add_white.png);
    width: 1.54rem;
  }
}
</style>
<style scoped src="@/style/module/table.css"></style>
<style scoped src="@/style/clue_manage/clue_manage.css"></style>